﻿using System;
using System.ComponentModel.DataAnnotations;
using Abp.Authorization.Users;
using Abp.Extensions;

namespace AVISOutBound.SSOServer.Authorization.Users
{
    /// <summary>
    /// 用户信息表
    /// </summary>
    public class User : AbpUser<User>
    {

        public const string DefaultPassword = "123qwe";
        /// <summary>
        /// 短信验证码
        /// </summary>
        [StringLength(50)]
        public string SmSCode { get; set; }
        /// <summary>
        /// 验证码过期时间,过期时间内不允许再次发送验证码(1.设置验证码有效时间,2.有效时间内不允许再次发送验证码，防刷)
        /// </summary>
        public DateTime? SmsCodeSendLockoutEndDateUtc{ get; set; }
        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public bool Sex { get; set; }
        /// <summary>
        /// 信用卡号
        /// </summary>
        [StringLength(50)]
        public string CreditCard { get; set; }
        /// <summary>
        /// 信用卡号过期时间
        /// </summary>
        public DateTime? CreditCardExpireDay { get; set; }
        /// <summary>
        /// 驾照号码
        /// </summary>
        [StringLength(50)]
        public string DrivingLicenseNo { get; set; }
        /// <summary>
        /// 联系地址
        /// </summary>
        [StringLength(500)]
        public string Address { get; set; }

        public static string CreateRandomPassword()
        {
            return Guid.NewGuid().ToString("N").Truncate(16);
        }

        public static User CreateTenantAdminUser(int tenantId, string emailAddress)
        {
            var user = new User
            {
                TenantId = tenantId,
                UserName = AdminUserName,
                Name = AdminUserName,
                Surname = AdminUserName,
                EmailAddress = emailAddress
            };

            user.SetNormalizedNames();

            return user;
        }
    }
}
